﻿//-----------------------------------赵洪科------------------------------------------//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///OrderDetail 的摘要说明
/// </summary>
public partial class OrderDetail
{
    DataTableDataContext db = new DataTableDataContext();

    //增加到OrderDetail
    public void insertTo( int  id2, long id3, string name, decimal p, int n = 1)
    {
        OrderDetail orderdetail = new OrderDetail
        {
            //orderDetailId = id1,
            orderListId = id2,
            productId = id3,
            productName = name,
            price = p,
            number = n
        };
        db.OrderDetail.InsertOnSubmit(orderdetail);
        db.SubmitChanges();
    }
    //删除某一订单信息
    public void removeFr(int id1)
    {
        var orderdetails = from b in db.OrderDetail where b.orderDetailId == id1 select b;
        foreach (var orderdetail in orderdetails)
        {
            db.OrderDetail.DeleteOnSubmit(orderdetail);
            db.SubmitChanges();
        }
    }
    //按ID查找订单信息
    public IEnumerable<OrderDetail> returnOrderDetail1(int id1)
    {
        var orderdetail = from b in db.OrderDetail where b.orderDetailId == id1 select b;
        return orderdetail;

    }
    //按书的ID查找订单
    public IEnumerable<OrderDetail> returnOrderDetail2(int id2)
    {
        var orderdetail = from b in db.OrderDetail where b.productId == id2 select b;
        return orderdetail;
    }
}